package com.itkaige.boot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
//@EnableWebMvc
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index.html").setViewName("index");

//        registry.addViewController("/").setViewName("dashboard");
        registry.addViewController("/dashboard.html").setViewName("dashboard");


        registry.addViewController("/list.html").setViewName("list");

        registry.addViewController("/add.html").setViewName("add");

        registry.addViewController("/update.html").setViewName("update");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyHandlerIntercepter())
                .addPathPatterns("/**").excludePathPatterns("/index.html",
                "/","/user/login","/css/signin.css","/css/bootstrap.min.css",
                "/img/bootstrap-solid.svg");
    }
}
